package com.zhanghang.vending_machine.controller;

import com.zhanghang.vending_machine.common.result.Result;
import com.zhanghang.vending_machine.domain.dto.GoodDto;
import com.zhanghang.vending_machine.service.GoodService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/good")
@Slf4j
@Api(tags = "自动售货机接口管理")
@RequiredArgsConstructor
public class AdminController {

    private final GoodService goodService;


    @PostMapping("/add")
    @ApiOperation("新增商品")
    public Result addGood(@RequestBody GoodDto goodDto){
        log.info("新增商品：{}",goodDto);

        goodService.addGood(goodDto);

        return Result.success();

    }
}
